package com.yipao.db.dao.goods;

import java.util.List;

import com.yipao.db.domain.goods.vo.goods.GoodsAdminListReq;
import com.yipao.db.domain.goods.vo.goods.GoodsAdminListResp;
import org.apache.ibatis.annotations.Param;
import com.yipao.db.domain.goods.Goods;
import com.yipao.db.domain.goods.vo.goods.GoodsExample;

/**
 * 商品
 *
 * @author tianhao
 */
public interface GoodsMapper {

    long countByExample(GoodsExample example);


    int deleteByExample(GoodsExample example);


    int deleteByPrimaryKey(Integer id);

    int add(GoodsAdminListResp vo);


    int insertSelective(Goods record);


    Goods selectOneByExample(GoodsExample example);


    Goods selectOneByExampleSelective(@Param("example") GoodsExample example, @Param("selective") Goods.Column... selective);


    Goods selectOneByExampleWithBLOBs(GoodsExample example);


    List<Goods> selectByExampleSelective(@Param("example") GoodsExample example, @Param("selective") Goods.Column... selective);

    /**
     * 分页查询(管理端)
     *
     * @param example
     * @return
     */
    List<GoodsAdminListResp> selectByExampleWithBLOBs(GoodsAdminListReq example);


    List<Goods> selectByExample(GoodsExample example);


    Goods selectByPrimaryKeySelective(@Param("id") Integer id, @Param("selective") Goods.Column... selective);


    Goods selectByPrimaryKey(Integer id);


    Goods selectByPrimaryKeyWithLogicalDelete(@Param("id") Integer id, @Param("andLogicalDeleted") boolean andLogicalDeleted);


    int updateByExampleSelective(@Param("record") Goods record, @Param("example") GoodsExample example);


    int updateByExampleWithBLOBs(@Param("record") Goods record, @Param("example") GoodsExample example);


    int updateByExample(@Param("record") Goods record, @Param("example") GoodsExample example);


    int updateByPrimaryKeySelective(Goods record);


    int updateByPrimaryKeyWithBLOBs(Goods record);


    int updateByPrimaryKey(Goods record);


    int logicalDeleteByExample(@Param("example") GoodsExample example);


    int logicalDeleteByPrimaryKey(Integer id);

    /**
     * 查询指定设备绑定的商品列表
     *
     * @param devId   设备id
     * @param deleted 删除状态
     * @return
     */
    List<Goods> queryDevGoodsByDevId(@Param("devId") String devId, @Param("deleted") Integer deleted);

    /**
     * 查询设备下的商品列表
     *
     * @param devId         设备id
     * @param categoryId    分类id
     * @param keywords      查询关键字
     * @param orderByClause 排序字段
     * @param deleted       删除状态
     * @param isOnSale      设备在线状态
     * @return
     */
    List<Goods> querySelectiveByDevId(@Param("devId") Integer devId, @Param("categoryId") Integer categoryId,
                                      @Param("keywords") String keywords, @Param("orderByClause") String orderByClause,
                                      @Param("deleted") Integer deleted,
                                      @Param("isOnSale") Integer isOnSale);

    /**
     * 根据配方id,查询商品
     *
     * @param formulaId 配方id
     * @param deleted   删除状态
     * @return
     */
    int queryCountGoodsByFormulaId(@Param("formulaId") Integer formulaId, @Param("deleted") Integer deleted);
}
